import instance from './client'

// 获取node信息 接口
export var NODE_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/nodes",{params})
}
export var NODE_DETAIL_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/nodes/detail",{params})
}
export var NAMESPACE_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/namespaces/detail",{params})
}
export var DEPLOYMENT_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/deployments/detail",{params})
}
export var SERVICE_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/services/detail",{params})
}
export var INGRESS_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/ingress/detail",{params})
}
export var CONFIGMAP_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/configmap/detail",{params})
}
export var SECRET_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/secret/detail",{params})
}
export var PV_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/pv/detail",{params})
}
export var PVC_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/pvc/detail",{params})
}
export var STATEFULSET_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/statefulsets/detail",{params})
}
export var POD_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/detail",{params})
}
export var POD_LOGS = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/logs",{params})
}
export var POD_CONTAINERS = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/container",{params})
}
export var DELETE_NAMESPACE = (name)=> instance.delete(`/api/v1/kubernetes/namespaces/${name}`)
export var CREATE_NAMESPACE = (data)=> instance.post('/api/v1/kubernetes/namespaces',data)
export var UPDATE_NAMESPACE = (data)=> instance.put("/api/v1/kubernetes/namespaces/",data)
export var UPDATE_DEPLOYMENT = (data)=> instance.put("/api/v1/kubernetes/deployments/",data)
export var UPDATE_SERVICE = (data)=> instance.put("/api/v1/kubernetes/services/",data)
export var UPDATE_INGRESS = (data)=> instance.put("/api/v1/kubernetes/ingress/",data)
export var UPDATE_CONFIGMAP = (data)=> instance.put("/api/v1/kubernetes/configmap/",data)
export var UPDATE_SECRET = (data)=> instance.put("/api/v1/kubernetes/secret/",data)
export var UPDATE_PV = (data)=> instance.put("/api/v1/kubernetes/pv/",data)

export var UPDATE_PVC = (data)=> instance.put("/api/v1/kubernetes/pvc/",data)

export var UPDATE_STATEFULSET = (data)=> instance.put("/api/v1/kubernetes/statefulsets/",data)

export var UPDATE_DAEMONSET = (data)=> instance.put("/api/v1/kubernetes/daemonsets/",data)

export var UPDATE_POD = (data)=> instance.put("/api/v1/kubernetes/pods/",data)

export var RESTART_DEPLOYMENT = (data)=> instance.post("/api/v1/kubernetes/deployments/restart",data)

export var UPDATE_DEPLOYMENTSCALE = (data)=> instance.post("/api/v1/kubernetes/deployments/scale",data)

export var DELETE_DEPLOYMENT = (data)=> instance.delete(`/api/v1/kubernetes/deployments/`,{data:data})
export var DELETE_SERVICE = (data)=> instance.delete(`/api/v1/kubernetes/services/`,{data:data})
export var DELETE_INGRESS = (data)=> instance.delete(`/api/v1/kubernetes/ingress/`,{data:data})
export var DELETE_CONFIGMAP= (data)=> instance.delete(`/api/v1/kubernetes/configmap/`,{data:data})
export var DELETE_SECRET= (data)=> instance.delete(`/api/v1/kubernetes/secret/`,{data:data})
export var DELETE_PV= (data)=> instance.delete(`/api/v1/kubernetes/pv/`,{data:data})

export var DELETE_DAEMONSET = (data)=> instance.delete(`/api/v1/kubernetes/daemonsets/`,{data:data})

export var NAMESPACE_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/namespaces",{params})
}
export var SERVICE_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/services",{params})
}
export var INGRESS_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/ingress",{params})
}
export var CONFIGMAP_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/configmap",{params})
}

export var SECRET_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/secret",{params})
}
export var PV_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/pv",{params})
}
export var PVC_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/pvc",{params})
}
// 获取pod信息
export var POD_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/pods",{params})
}
// 获取deployment信息
export var DEPLOYMENT_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/deployments",{params})
}
export var DAEMONSET_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/daemonsets",{params})
}
export var STATEFULSET_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/statefulsets",{params})
}
export var DAEMONSET_DETAIL = (params)=> {
    return instance.get("/api/v1/kubernetes/daemonsets/detail",{params})
}
export var DEPLOYMENT_POD_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/deployForPod",{params})
}
export var STATEFULSET_POD_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/statefulForPod",{params})
}
export var DAEMONSET_POD_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/daemonsetForPod",{params})
}
export var CREATE_DEPLOYMENT = (data)=> instance.post('/api/v1/kubernetes/deployments/',data)
export var CREATE_SERVICE = (data)=> instance.post('/api/v1/kubernetes/services/',data)
export var CREATE_INGRESS = (data)=> instance.post('/api/v1/kubernetes/ingress/',data)

export var CREATE_STATEFULSET = (data)=> instance.post('/api/v1/kubernetes/statefulsets/',data)

export var CREATE_DAEMONSET = (data)=> instance.post('/api/v1/kubernetes/daemonsets/',data)
export var CREATE_CONFIGMAP = (data)=> instance.post('/api/v1/kubernetes/configmap/',data)
export var CREATE_SECRET = (data)=> instance.post('/api/v1/kubernetes/secret/',data)

// 获取每个namespace分别有多少pod数量
export var GET_NS_PODS_COUNT = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/numnp",{params})
}
export var DELETE_POD = (data)=> instance.delete(`/api/v1/kubernetes/pods/`,{data:data})

export var GET_NS_DEPLOYMENT_COUNT = (params)=> {
    return instance.get("/api/v1/kubernetes/deployments/numdp",{params})
}
export var GET_NS_POD_COUNT = (params)=> {
    return instance.get("/api/v1/kubernetes/pods/numnp",{params})
}
export var PODS_LIST = (params)=> {
    return instance.get("/api/v1/kubernetes/pods",{params})
}
export var WORKFLOW_LIST = (params)=> {
    return instance.get("/api/v1/workflow",{params})
}
